package Strategy;

import Strategy.cashier.BuyOneGetOneCashier;
import Strategy.cashier.Cashier;
import Strategy.cashier.NormalCashier;
import Strategy.cashier.RebateCashier;
import Strategy.constants.CasherEnum;

/**
 * @author duanzhizhou
 * @date 2024/9/25
 */
public class CashContext {
    
    private Cashier cashier;
    
    public CashContext(CasherEnum casherEnum) {
        switch (casherEnum) {
            case HALF:
                this.cashier = new RebateCashier(0.5);
                break;
            case NORMAL:
                this.cashier = new NormalCashier();
                break;
            case QUARTER:
                this.cashier = new RebateCashier(0.25);
                break;
            case BUY_ONE_GET_ONE:
                this.cashier = new BuyOneGetOneCashier();
                break;
        }
    }
    
    public double getMoney(double price, int num) {
        return cashier.check(price, num);
    }
    
}
